package com.campus.web.control;

import com.campus.service.AssistantService;
import com.campus.web.vo.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * @author HLQ
 * @date 2024/11/23 1:10
 */
@Controller
@RequestMapping("/assistants")
@Slf4j
@Validated
public class AssistantController {

    @Autowired
    private AssistantService assistantService;

    // 将学生分配到指定班级的组
    @PostMapping("/classes/students/groups/")
    @ResponseBody
    public ResponseResult<String> addClassStudentGroup(
            @RequestParam @NotNull Integer classId,
            @RequestParam @NotNull Integer studentId,
            @RequestParam @NotNull Integer studentGroupId) {

        log.info("classId: {}, studentId: {}, studentGroupId: {}", classId, studentId, studentGroupId);

        // 调用服务层方法处理业务逻辑
        assistantService.addClassStudentGroup(classId, studentId, studentGroupId);

        // 返回统一格式的成功响应
        return ResponseResult.ok("学生成功加入班级组");
    }
}
